package com.hqd.jjvm.classformat.attributeinfo;

import com.hqd.jjvm.classformat.ClassFile;
import com.hqd.jjvm.util.HexStrTransformUtil;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class Signature extends AttributeInfo {
    private Integer signatureIndex;

    public Signature(Integer attributeNameIndex, Integer attributeLength, Integer signatureIndex) {
        super(attributeNameIndex, attributeLength);
        this.signatureIndex = signatureIndex;
    }

    @Override
    protected Signature newAttributeInfo(Integer attributeNameIndex, Integer attributeLength, ClassFile classFile) {
        this.signatureIndex = HexStrTransformUtil.parseHexToInt(classFile.readU2());
        return this;
    }
}
